<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
 <script type="text/javascript">
        var url;

        function searchUser() {
            $("#dg").datagrid('load', {
                "userName": $("#s_userName").val()
            });
        }

        function deleteUser() {
            var selectedRows = $("#dg").datagrid('getSelections');
            if (selectedRows.length == 0) {
                $.messager.alert("系统提示", "请选择要删除的数据！");
                return;
            }
            var strIds = [];
            for (var i = 0; i < selectedRows.length; i++) {
                strIds.push(selectedRows[i].id);
            }
            var ids = strIds.join(",");
            $.messager.confirm("系统提示", "您确认要删除这<font color=red>"
                    + selectedRows.length + "</font>条数据吗？",function (r) {
                if (r) {
                    $.post("${pageContext.request.contextPath}/user/delete.do", {
                        ids: ids
                    }, function (result) {
                        if (result.success) {
                            $.messager.alert("系统提示", "数据已成功删除！","info");
                            $("#dg").datagrid("reload");
                        } else {
                            $.messager.alert("系统提示", "数据删除失败！","error");
                        }
                    }, "json");
                }
            });

        }

        function opentestcaseAddDialog() {
            $("#dlg").dialog("open").dialog("setTitle", "添加用例");
            url = "${pageContext.request.contextPath}/projectcase/casesave.do";
        }
        function table(){
        	
        }

        function saveUser() {
            $("#fm").form("submit", {
                url: url,
                onSubmit: function () {
                    return $(this).form("validate");
                },
                success: function (result) {
                    $.messager.alert("系统提示", "保存成功");
                    resetValue();
                    $("#dlg").dialog("close");
                    $("#dg").datagrid("reload");
                }
            });
        }
        function saveCase() {
            $("#fm").form("submit", {
                url: url,
                onSubmit: function () {
                    return $(this).form("validate");
                },
                success: function (result) {
                    $.messager.alert("系统提示", "保存成功");
                    resetValue();
                    $("#dlg").dialog("close");
                    $("#dg").datagrid("reload");
                }
            });
        }

        function opentestcaseModifyDialog() {
            var selectedRows = $("#dg").datagrid('getSelections');
            if (selectedRows.length != 1) {
                $.messager.alert("系统提示", "请选择一条要编辑的数据！");
                return;
            }
            var row = selectedRows[0];
            $("#dlg").dialog("open").dialog("setTitle", "编辑用户信息");
            $('#fm').form('load', row);
            $("#password").val("******");
          url = "${pageContext.request.contextPath}/projectcase/show.do?id=" + row.id;
           
            
        }
        
        function opentestcasedetailModifyDialog() {
        	 url = "${pageContext.request.contextPath}/projectcase/show.do?";
        	 alert(url);
        	 var rows = $("#dg").datagrid('getData').rows;
        	 var selectedRows = $("#dg").datagrid('getSelections');
        	 var row = selectedRows[0];
        	 var testcase=row.name;
        	 alert(testcase);
                             
            $("#dlgb").dialog("open").dialog("setTitle", "编辑步骤");
            $.ajax({
                type : "get",// 请求方式
                url : url,// 发送请求地址
                data:{'testcase':testcase},
                // 请求成功后的回调函数有两个参数
         
                success : function(result) {
                	 alert(result);
                //	 document.getElementById("path").value = path1[0];
                
                	 var tr='<tr><td><a href="javascript:name()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-add" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-add">&nbsp;</span></span></span></a></td>'+
         			'<td><a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-edit" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-edit">&nbsp;</span></span></span></a></td>'+
         			'<td><a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-remove" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-remove">&nbsp;</span></span></span></a></td>'+
         			'<td><a><select name="way">'+
         			'<option value="volvo1"></option>'+
         						'<option value="volvo">id</option>'+
         						'<option value="saab">xpath</option>'+
         						'<option value="fiat">name</option>'+
         						'<option value="audi">classname</option>'+
         				'</select></a></td>'+
         			'<td>定位元素：</td><td><input type="text" id="path" value=testcase, class="easyui-validatebox" style="width:100px; height:15px;" ></input>&nbsp;</td>'+
         			'<td><a>操作步骤：<select name="action"><option value="volvo1">请选择</option><option value="volvo">click</option><option value="saab">sendkeys</option><option value="fiat">iframe</option><option value="audi">doubleclick</option></select></a></td>'+
         				'<td>参数内容：</td><td><input type="text" id="content" name="content" class="easyui-validatebox" style="width:80px; height:15px;" />&nbsp;</td>'+
         				'<td>预期值：</td><td><input type="text" id="exceptresult" name="exceptresult" class="easyui-validatebox" style="width:80px; height:15px;"/>&nbsp;</td>'+
         				'<td><a>步骤类型：<select name="action"><option value="volvo1">UI自动化</option><option value="volvo">接口自动化</option><option value="saab">移动端</option></select></a></td></tr>'
         			
         			
         			
         			
         				$("#addTable").append(tr);
                	 
                }
         
            });
          
           alert("bbbbbbbbb");
            $('#fmb').form('load', row);
            $("#name").val("******");
            url = "${pageContext.request.contextPath}/projectcase/show.do?";
         //   url = "${pageContext.request.contextPath}/user/save.do?id=" + row.id;
        }

        function resetValue() {
            $("#userName").val("");
            $("#password").val("");
        }

        function closeUserDialog() {
            $("#dlg").dialog("close");
            resetValue();
        }
        function closetestcaseDialog() {
            $("#dlgb").dialog("close");
            resetValue();
        }
    </script>
    <script type="text/javascript">
    
		function name() {
			var tr='<tr><td><a href="javascript:name()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-add" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-add">&nbsp;</span></span></span></a></td>'+
			'<td><a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-edit" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-edit">&nbsp;</span></span></span></a></td>'+
			'<td><a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-remove" plain="true" group="" id=""><span class="l-btn-left"><span class="l-btn-text"><span class="l-btn-empty icon-remove">&nbsp;</span></span></span></a></td>'+
			'<td><a><select name="way">'+
			'<option value="volvo1"></option>'+
						'<option value="volvo">id</option>'+
						'<option value="saab">xpath</option>'+
						'<option value="fiat">name</option>'+
						'<option value="audi">classname</option>'+
				'</select></a></td>'+
			'<td>定位元素：</td><td><input type="text" id="path" name="path" class="easyui-validatebox" style="width:100px; height:15px;" />&nbsp;</td>'+
			'<td><a>操作步骤：<select name="action"><option value="volvo1">请选择</option><option value="volvo">click</option><option value="saab">sendkeys</option><option value="fiat">iframe</option><option value="audi">doubleclick</option></select></a></td>'+
				'<td>参数内容：</td><td><input type="text" id="content" name="content" class="easyui-validatebox" style="width:80px; height:15px;" />&nbsp;</td>'+
				'<td>预期值：</td><td><input type="text" id="exceptresult" name="exceptresult" class="easyui-validatebox" style="width:80px; height:15px;"/>&nbsp;</td>'+
				'<td><a>步骤类型：<select name="action"><option value="volvo1">UI自动化</option><option value="volvo">接口自动化</option><option value="saab">移动端</option></select></a></td></tr>'
			
			
			
			
				$("#addTable").append(tr);


				
		}
    </script>
    
</head>
<body style="margin: 1px;">
	<table id="dg" title="用例管理" class="easyui-datagrid" fitColumns="true"
		pagination="true" rownumbers="true"
		url="${pageContext.request.contextPath}/projectcase/list.do" fit="true"
		toolbar="#tb">
		<thead>
			<tr>
				<th field="cb" checkbox="true" align="center"></th>
				<th field="id" width="50" align="center">编号</th>
				<th field="name" width="100" align="center">用例名称</th>
			</tr>
		</thead>
	</table>
	<div id="tb">
		<div>
			<a href="javascript:opentestcaseAddDialog()"
				class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a> <a
				href="javascript:opentestcaseModifyDialog()"
				class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a> <a
				href="javascript:deleteUser()" class="easyui-linkbutton"
				iconCls="icon-remove" plain="true">删除</a> <a
				href="javascript:opentestcasedetailModifyDialog()" method="post"
				class="easyui-linkbutton" iconcls="icon-add" plain="true">关联用例步骤</a>
		</div>
		<div>
			&nbsp;用例名称：&nbsp;<input type="text" id="s_userName" size="20"
				onkeydown="if(event.keyCode==13) searchUser()" /> <a
				href="javascript:searchUser()" class="easyui-linkbutton"
				iconCls="icon-search" plain="true">搜索</a>
		</div>
	</div>

	<div id="dlg" class="easyui-dialog"
		style="width: 620px; height: 250px; padding: 10px 20px" closed="true"
		buttons="#dlg-button">
		<form id="fm" method="post">
			<table cellspacing="8px">
				<tr>
					<a></a>
					<td>用例名称：</td>
					<td><input type="text" id="name" name="name"
						class="easyui-validatebox" required="true" />&nbsp;<font
						color="red">*</font></td>
				</tr>
			</table>
		</form>
	</div>

	<div id="dlgb" class="easyui-dialog"
		style="width: 1180px; height: 500px; padding: 10px 10px" closed="true"
		buttons="#dlg-buttons">
		<form id="fmb" method="post">
			<table cellspacing="8px" id ="addTable">
				<tr><td>
				<a href="javascript:name()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-add" plain="true" group="" id=""></a></td>
				<td>
				<a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-edit" plain="true" group="" id=""></a></td>
				<td>
				<a href="javascript:xxxx()" class="easyui-linkbutton l-btn l-btn-plain" iconcls="icon-remove" plain="true" group="" id=""></a></td> 
					<td><a><select name="way">
					<option value="volvo1"></option>
								<option value="volvo">id</option>
								<option value="saab">xpath</option>
								<option value="fiat">name</option>
								<option value="audi">classname</option>
						</select></a></td>
					<td>定位元素：${requestScope.ele}</td>
					<td><input type="text" id="path" name="path"
						class="easyui-validatebox" style="width:100px; height:15px;"  />&nbsp;</td>
					<td><a>操作步骤：<select name="action">
					<option value="volvo1">请选择</option>
								<option value="volvo">click</option>
								<option value="saab">sendkeys</option>
								<option value="fiat">iframe</option>
								<option value="audi">doubleclick</option>
						</select></a></td>
						<td>参数内容：</td>
					<td><input type="text" id="content" name="content"
						class="easyui-validatebox" style="width:80px; height:15px;" />&nbsp;</td>
						<td>预期值：</td>
					<td><input type="text" id="exceptresult" name="exceptresult"
						class="easyui-validatebox" style="width:80px; height:15px;"/>&nbsp;</td>
						<td><a>步骤类型：<select name="action">
					<option value="volvo1">UI自动化</option>
								<option value="volvo">接口自动化</option>
								<option value="saab">移动端</option>
						</select></a></td>
					<!--  	<td>用例id：</td>
					<td><input type="text" id="caseid" name="caseid"
						class="easyui-validatebox" />&nbsp;</td>-->
				</tr>
			</table>
		</form>
	</div>

	<div id="dlg-buttons">
    <a href="javascript:saveUser()" class="easyui-linkbutton"
       iconCls="icon-ok">保存1111</a> <a href="javascript:closetestcaseDialog()"
                                   class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
<div id="dlg-button">
    <a href="javascript:saveCase()" class="easyui-linkbutton"
       iconCls="icon-ok">保存11</a> <a href="javascript:closeUserDialog()"
                                   class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
</body>
</html>